package dk.dtu.is.main.jess;
import jess.*;

public class MainJess {
	private Rete engine;
	public MainJess() {
		engine = new Rete();
		runEngine("clp/PowerlabClient.clp");
	}
	// TODO substitude each assert(Event... with java function call. Implement a generic function to update GUI. 
	private void runEngine(String file) {
		try {
			engine.batch(file);
			engine.runUntilHalt();
//			Fact f = engine.findFactByFact(new Fact(engine.findDeftemplate("MAIN::Event")));
//			
//			if (f!=null)
//				System.out.println(f.toString());
//			else
//				System.out.println("Fact not found");
//			Iterator it = new FilteringIterator(engine.listFacts(),
//                    new Filter.ByModule("MAIN"));
//	        while (it.hasNext()) {
//	        	Object value = it.next();
////	        	if (value.toString().toLowerCase().contains("event"))
////	        		parseandupdate(value);
//
//	        		//System.out.println("Hello " +value);//do something    .process();
//	        }
			
		} catch (JessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	private void parseandupdate(Object value){
//		Fact f = 
		System.out.println(value.toString().indexOf("property") + value.toString());
//		value.getSlotValue("property");     //getSlotValue
	}
    
}
